package br.com.saeng2D.formulario.caixa;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

import br.com.saeng2D.superficie.Superficie;

public abstract class Dialogo extends JDialog {
	private static final long serialVersionUID = 1L;
	protected JButton buttonAdicionar = new JButton("Adicionar");
	protected JButton buttonCancelar = new JButton("Cancelar");
	protected JPanel panelCentral = new JPanel(null);
	protected Superficie superficie;
		
	public Dialogo(Superficie superficie) {
		super(superficie.getFormularioPrincipal(), true);
		this.superficie = superficie;
		montarLayout();
		registrarEvento();
	}

	public final void registrarEvento() {
		buttonCancelar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
	}

	public final void montarLayout() {
		setLayout(new BorderLayout());
		add(BorderLayout.CENTER, panelCentral);	
		JPanel panelSul = new JPanel(new BorderLayout());
		panelSul.add(BorderLayout.WEST, buttonCancelar);
		panelSul.add(BorderLayout.EAST, buttonAdicionar);
		add(BorderLayout.SOUTH, panelSul);
	}

	public Superficie getSuperficie() {
		return superficie;
	}
	
	public abstract void adicionarNaSuperficie();
}